package com.c8a.validation.controller;

import com.c8a.validation.entity.Student;
import com.c8a.validation.entity.StudentVO;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 校验一:在Controller上进行校验
 *
 * @Author C8A
 * @Date 2022-04-23 20:04
 * @Email 1912327276@qq.com
 */

@RestController
public class StudentController {

    /**
     * {"id":"1","name":"eddie","title":"初级开发工程师","age": 22 "email": 23123}
     *
     * @param student
     * @return
     */
    @PostMapping("/valid1")
    public ResponseEntity<Student> valid1(@Valid @RequestBody Student student) {
        return ResponseEntity.ok(student);
    }

    /**
     * @param students
     * @return
     */
    @PostMapping("/valid2")
    public ResponseEntity<StudentVO> valid2(@Valid @RequestBody StudentVO students) {
        return ResponseEntity.ok(students);
    }
}
